<template>
 <div>
    <my-div class="exchange">
     <head></head>
      <my-div class="transfer-choose">
        <div class="logo">
          <image style="width:160px;height:96px;" src="root:img/logo@2x.png"></image>
          <text style="color:rgba(60,71,98,1);font-size:48px;margin-top:36px;">AXSwap国际交易币</text>
          <text style="color:rgba(154,156,164,1);font-size:30px;margin-top:18px;">version{{versionName}}</text>
        </div>
         <div class="choose-currency">
          <text class="currency-name">用户协议</text>
          <div class="currency-wrapper" @click="get_service_require">
             <!-- <text class="currency-value">{{current_wallet.account_id}}</text> -->
            <image style="width:18px;height:32px;margin-left:24px;" src="root:img/home/right@2x.png"></image>
          </div>
        </div>
        <div class="choose-currency">
          <text class="currency-name">版本更新</text>
          <div class="currency-wrapper" @click="sure_update">
             <text style="color:rgba(154,156,164,1);font-size:30px;">版本{{versionName}}</text>
             <div v-if="dot" class="dot"></div>
            <image style="width:18px;height:32px;margin-left:24px;" src="root:img/home/right@2x.png"></image>
          </div>
        </div>
        <div class="choose-currency">
        <text class="currency-name">AXSwap产品介绍</text>
        <div class="currency-wrapper" @click="get_product_intro">
            <!-- <my-switch></my-switch>   -->
          <image style="width:18px;height:32px;margin-left:24px;" src="root:img/home/right@2x.png"></image>
        </div>
        </div>
      </my-div>
      <!-- <alert-input ref='valid_mail' :validate="valid_email" type="email" title="验证邮箱" placeholder="请输入邮箱号码" @success="success"></alert-input>  -->
  </my-div>
 </div>
</template>
<script>
import Utils from '../../utils/index.js'

export default {
  data(){
    return {
      versionName:'',
      dot:false,
      url:''
    }
  },
  created() {
    
  },
  methods: {
    onLoad(){
      var env=weex.requireModule('env')
      this.versionName = env.versionName()
      this.check_updater()
    },
    // 获取服务条款
    get_service_require(){
      
      this.$http.get('index/getTermOfService',{termType:1},(res)=>{
        this.push('root:pages/web/kx_web.js',{source:res.returnObject.content,title:'用户协议'})
      })
    },
    // 获取产品介绍
    get_product_intro(){
       this.$http.get('index/getTermOfService',{termType:2},(res)=>{
        this.push('root:pages/web/kx_web.js',{source:res.returnObject.content,title:'产品介绍'})
      })
    },
     // 检测更新
   check_updater(){
      let app;
      var env=weex.requireModule('env')
      Utils.isIOS() ? app = 2 : app = 1
      this.$http.get('index/checkupdate',{appType:app,appNumber:env.versionCode()},(res)=>{
        if(res.result){
          this.dot = true
          this.url = res.result
        }
      })  
   },
   sure_update(){
     if(!this.dot) return 
      var updater=weex.requireModule('updater')
      var device=weex.requireModule('device')
      this.modal.confirm({message:'当前已有新版本，是否更新',okTitle:'更新',cancelTitle:'下次再说'},(val)=>{
        if(val === '更新'){
          this.toast('AXSwap已在后台下载,请在控制栏中查看进度。')
          Utils.isIOS() ? device.openUrl(this.url) : updater.download(this.url)
        }
      })
   }
  },
}
</script>
<style scoped>
.logo{
  width: 750px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  margin-top: 200px;
  margin-bottom: 100px;
}
  .wrapper{
  display: flex;
  flex-direction: row;
}
.exchange{
  flex: 1;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
}
.sure-btn{
  position: absolute;
  bottom: 30px;
  left: 30px;
}
.transfer-choose{
  width: 720px;
  padding-left: 30px;
}
.transfer-title{
  margin-top: 24px;
  font-size: 48px;
  font-family: PingFang SC;

  margin-bottom: 104px;
}
.choose-currency{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 690px;
  height: 100px;
  border-bottom-width: 1px;
  border-bottom-style: solid;
  border-bottom-color: rgba(233,233,233,1);
}
.currency-value{
  font-size: 28px;
  max-width: 200px;
  lines:1;
  color: rgba(70,120,245,1);
}
.currency-name{
  font-size: 30px;
  color: rgba(60,71,98,1);
}
.currency-wrapper{
  display: flex;
  flex-direction: row;
  height: 100px;
  min-width: 200px;
  align-items: center;
  justify-content: flex-end;
}
.safe-range{
  display: flex;
  flex-direction: row;
  margin-bottom: 20px;
}
.dot{
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: red;
  margin-left: 10px;
}
</style>